
class flg
{
    public static int m=0;
    public  void add2()
    {
        synchronized (this)
        {
            m++;
        }
    }
    public synchronized void add()
    {
        m++;

    }
}


public class text100
{
    public static void main(String[] args) {
        flg m=new flg();

        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                int i = 0;
                for (i = 0; i < 50000; i++) {
                   m.add2();

                }

            }
        });
        Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                int i = 0;
                for (i = 0; i < 50000; i++) {
                    m.add2();

                }

            }
        });
        thread1.start();
        thread2.start();
        try {
            thread1.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        try {
            thread2.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(flg.m);
    }






}